package com.baihan.angus.app.game.basic;

import android.app.Application;

import androidx.appcompat.app.AppCompatDelegate;

import com.alibaba.android.arouter.launcher.ARouter;
import com.baihan.angus.app.game.basic.configs.BasicConfig;

public abstract class BaseApplication extends Application {


    private static BaseApplication mApplication;
    private String deviceNo = "";
    private boolean mAppServiceKilled = true;

    @Override
    public void onCreate() {
        super.onCreate();
        mApplication = this;

        if (BuildConfig.DEBUG) {
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(this);
        setDayNightMOde();
    }


    public static BaseApplication getApplication(){
        return mApplication;
    }

    public void setDayNightMOde(){
        AppCompatDelegate.setDefaultNightMode(BasicConfig.getInstance().isDayMode()
                ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES);
    }

    public String getDeviceNo() {
        return deviceNo;
    }

    public void setDeviceNo(String deviceNo) {
        this.deviceNo = deviceNo;
    }

    public boolean ismAppServiceKilled() {
        return mAppServiceKilled;
    }

    public synchronized void setAppServiceKilled(boolean mAppServiceKilled) {
        this.mAppServiceKilled = mAppServiceKilled;
    }

    public abstract String getAppServerToken();
}
